import { Column, Entity, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
import { BaseEntity } from './BaseEntity';
import { SysMenu } from './SysMenu';
import { SysRolePermission } from './SysRolePermission';
@Entity()
export class SysPermission extends BaseEntity {
  @Column({
    type: 'varchar',
    nullable: true,
    comment: '权限名'
  })
  name: string;

  @Column({
    type: 'varchar',
    nullable: true,
    comment: '权限代码'
  })
  code: string;

  @Column({
    default: false,
    type: 'boolean',
    comment: '是否禁用'
  })
  forbidden: boolean;

  @Column({
    type: 'varchar',
    nullable: true,
    comment: '备注'
  })
  remark: string;

  @ManyToOne(() => SysMenu, {
    onDelete: 'CASCADE',
    eager: true,
    nullable: true
  })
  @JoinColumn({
    name: 'menu_id'
  })
  menu: SysMenu;

  @OneToMany(() => SysRolePermission, s => s.SysPermissionId)
  SysRolePermission: SysRolePermission[];
}
